<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="online.rainy.dbhomework.pojo.Course" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>首页</title>
    <style>
        table {
            border-collapse: collapse;
        }

        table, td, th {
            border: 1px solid black;
        }
    </style>
</head>
<body>

    <table>
        <thead>
            <th>课程</th>
            <th>教师</th>
        </thead>
        <tbody>

        <% List<Course> list = (List<Course>) request.getAttribute("result"); %>
        <% for(int i=0;i<list.size();i++) { %>
            <tr>
                <td>
                    <jsp:element name="a">
                        <jsp:attribute name="href">
                            <c:url value="/detail"/>?cid=<%=list.get(i).getCid()%>
                        </jsp:attribute>
                        <jsp:body>
                            <%= list.get(i).getCname() %>
                        </jsp:body>
                    </jsp:element>
                </td>
                <td>
                    <%= list.get(i).getTeacher() %>
                </td>
            </tr>
        <% } %>
        </tbody>
    </table>

</body>
</html>